﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>Test</title>
        <style type="text/css">
        #introduction
        {
            background-color: #e1e1e1;
            font-size: 12px;
            margin: 5px;
            padding: 5px;
            clear: both;
        }
        </style>
		<script type="text/javascript">
        var dojoConfig = {
            baseUrl: "",
            tlmSiblingOfDojo: false,
            //packages: [
                //{ "name": "jquery", "location": 'modules', main: 'jquery-3.3.1.min' },
            //    { "name": "axios", "location": "modules", main: "axios.min" },
            //],
            paths: {
                'axios': 'modules/axios.min',
                'jquery': 'modules/jquery-3.3.1.min',
                'jquery.cookie': 'modules/jquery.cookie'
            },
            shim: {
                'jquery.cookie': { 'deps': ['jquery'] }
            }
        };
		</script>
		<script data-dojo-config="async: true" src="dojo.js"></script>
		
    </head>
    <body>
		<p>用户名： <input type="text" id="username" value="wyh" />
		密码： <input type="text" id="userpass" value="111111" />
        <input type="button" id="testauth" value="用户登录"/> <div id='jg'></div>
		<input type="button" id="testwzapi" value="testwzapi"/>
		<input type="button" id="getloginInfo" value="获得登录信息"/> <div id='jg'></div>
		<input type="button" id="getAllCode" value="获取代码表"/>
		<p>
		遥感核查测试</br>
		年度： <input type="text" id="sYear" value="2018" />
		<input type="button" id="BoundaryData" value="边界核查"/> <div id='jg'>
		<input type="button" id="DynamicVerification" value="核查动态"/> <div id='jg'>
		<input type="button" id="VerificationDisaster" value="核查灾害"/> <div id='jg'>
		<input type="button" id="TypeVerification" value="类型核查"/> <div id='jg'>
		<input type="button" id="VegetationCoverage" value="植被覆盖"/> <div id='jg'>
		</p>
		<p>
		EI指数计算与查询</br>
		年度： <input type="text" id="StartYear" value="2011" />
		<input type="text" id="EndYear" value="2012" />
		<input type="button" id="CalculationEIIndexList" value="EI指数计算的列表"/>
		<input type="button" id="EIIndexList" value="EI指数评价结果"/>
		<input type="button" id="EIIndexChangeList" value="EI指数变化评价结果"/>
		<input type="button" id="CalculationEIIndex" value="EI指数计算"/> <div id='jg'>
		<input type="button" id="VerificationDisaster" value="核查灾害"/> <div id='jg'>
		<input type="button" id="TypeVerification" value="类型核查"/> <div id='jg'>
		<input type="button" id="VegetationCoverage" value="植被覆盖"/> <div id='jg'>
		<input type="button" id="getEIParams" value="获得EI参数"/> <div id='jg'>
		</p>
		<p>
			<p>指定文件名： <input id="fileupload-tools-txt" type="text" name="filename" value="" /></p>
			<p> 上传文件： <input id="fileupload-tools" type="file" name="file" multiple="multiple"/></ p>
            <input type="button" value="上传" id="ajaxUpload" />
		</p>
		
    </body>
	<script type="text/javascript">
        require([
        "jquery",
        'modules/ApiClient',
		'modules/erstools',
		'modules/config',
		'modules/chatServer',
		 "dojo/dom","dojo/on", "dojo/domReady!"
		], function ($,ApiClient,erstools,config,chatServer,dom,on) {
			var tokenid = "";
			var stoken = "";
			$("#testauth").bind('click', function () {
                alert('zzh');
				var json_params={
					UserName:$("#username").val(),
					PasswordHash:$("#userpass").val()//,
					//client_id:'password_client'//'password_client'
				}
				alert(config.USWEBAPI);
				ApiClient.post(config.USWEBAPI+'Auth/login',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						$('#jg').append("登陆状态: "+reValues.data.reMessage+"<br/>");
						$('#jg').append("token: "+reValues.data.jwt+"<br/>");
						$('#jg').append("token-id: "+reValues.data.sid+"<br/>");
						tokenid = reValues.data.sid;
						stoken = reValues.data.jwt;
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
            });
			
			//http://localhost:9100/api/wz.api/test
			$("#testwzapi").bind('click', function () {
                alert('zzh');
				var json_params={
					cpage:'1',
					pageSize:'12',
					//total:'jczgroup_client'//'password_client'
					total:'0',
					WZT:{
						WZMC:'',//'毛',
						SDM:'1010001000100010001'
					}
				}
				ApiClient.post(config.WZWEBAPI+'SpeciesSearch',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
                
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
            });
			$("#ajaxUpload").click(function () {
                var json_params = {};
				json_params.files = document.getElementById('fileupload-tools').files;
				json_params.params = {filetype:'AscSource',filetime:'2018'};
				var param = new FormData();
				if(json_params.files.value == "") {
					alert("上传文件不能空");
					return ;
				}
				for(var i = 0; i< json_params.files.length; i++){//v==value　为arr项，i==index　为arr索引
					$('body').append("fileArray: "+json_params.files[i].name+"<br/>");
					param.append("fileArray"+i,json_params.files[i]);   // 文件对象
				}
				/*for(var key in json_params.params){
					$('body').append(key+": "+json_params.params[key]+"<br/>");
					param.append(key, json_params.params[key]);
				} */
				//param.append('file', uploadInput.files[0]);
				ApiClient.postfile(config.ERSWEBAPI+'Upload',param, '').then(function (resValue) {
					//alert("zzh");
					//alert(resValue.data);
					console.log(resValue);
					resValue.data.forEach(value => {
　　					console.log('forEach遍历:'+'--'+value);
						$('body').append("return: "+value.name+"-------------"+value.state+"<br/>");
					})
					//refunc(resValue);
				});
            });
			
			on(dom.byId("getAllCode"),"click",function(evt){
				alert(stoken);
				erstools.AllCode(stoken);
			});
			
			on(dom.byId("getloginInfo"),"click",function(evt){
				alert(tokenid);
				erstools.ersinit(tokenid);
			});
			
			on(dom.byId("BoundaryData"),"click",function(evt){
				alert(stoken);
				var ydid = dom.byId("sYear").value;
				erstools.BoundaryData(ydid,stoken);
			});

			on(dom.byId("DynamicVerification"),"click",function(evt){
				alert(stoken);
				var ydid = dom.byId("sYear").value;
				erstools.DynamicVerification(ydid,stoken);
			});

			on(dom.byId("VerificationDisaster"),"click",function(evt){
				alert(stoken);
				var ydid = dom.byId("sYear").value;
				erstools.VerificationDisaster(ydid,stoken);
			});

			on(dom.byId("TypeVerification"),"click",function(evt){
				alert(stoken);
				var ydid = dom.byId("sYear").value;
				erstools.TypeVerification(ydid,stoken);
			});

			on(dom.byId("VegetationCoverage"),"click",function(evt){
				alert(stoken);
				var ydid = dom.byId("sYear").value;
				erstools.VegetationCoverage(ydid,stoken);
			});
			on(dom.byId("CalculationEIIndexList"),"click",function(evt){
				alert(stoken);
				erstools.CalculationEIIndexList(stoken);
			});
			on(dom.byId("CalculationEIIndex"),"click",function(evt){
				alert(stoken);
				var ydid = dom.byId("StartYear").value;
				erstools.CalculationEIIndex(ydid,stoken);
			});

			on(dom.byId("EIIndexList"),"click",function(evt){
				alert(stoken);
				var syear = dom.byId("StartYear").value;
				erstools.EIIndexList(syear,stoken);
			});
			on(dom.byId("EIIndexChangeList"),"click",function(evt){
				alert(stoken);
				var syear = dom.byId("StartYear").value;
				var eyear = dom.byId("EndYear").value;
				erstools.EIIndexChangeList(syear,eyear,stoken);
			});
			//getEIParams
			on(dom.byId("getEIParams"),"click",function(evt){
				alert(stoken);
				var syear = dom.byId("StartYear").value;
				erstools.getEIParams(syear,stoken);
			});
		});
	</script>
</html>